<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport"
	content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<c:import url="/includes/header.jsp"></c:import>
<title></title>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="col-md-4"></div>
			<div class="col-md-4">
				<form class="form-horizontal" method="post" id="form">
					<input id="adminId" name="id" type="hidden" value="${adminId}">
					<div class="form-group">
						<label class="col-sm-3 control-label" for="content">当前密码:</label>
						<div class="col-sm-9">
							<input class="form-control" type="password" id="pwd" name="pwd"
								placeholder="当前密码">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label" for="content">输入新密码:</label>
						<div class="col-sm-9">
							<input class="form-control" type="text" id="newPwd"
								name="newPwd" placeholder="输入新密码">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-3 control-label" for="content">确认新密码:</label>
						<div class="col-sm-9">
							<input class="form-control" type="text" id="confirmPassword"
								name="confirmPassword" placeholder="确认新密码">
						</div>
					</div>
					<div class="col-md-8"></div>
					<div class="col-md-4">
						<button type="button" class="btn btn-primary btn-sm">确定</button>
					</div>
				</form>
			</div>
			<div class="col-md-4"></div>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
	$(function() {
		//保存修改的密码
		$(".btn")
				.click(
						function() {
							var pwd = $("#newPwd").val();
							var confirmPassword = $("#confirmPassword").val();
							if (pwd != confirmPassword) {
								bootbox.alert("确认输入新密码不正确！");
								return;
							}
							var url = "${pageContext.request.contextPath}/admin/setting/updatePwd.do";
							$.ajax({
								url : url,
								type : "post",
								dataType : "json",
								data : $("#form").serialize(),
								async : true,
								success : function(data) {
									if (data.code == "0") {
										bootbox.alert("修改密码成功");
									} else {
										bootbox.alert(data.msg);
									}
								},
								error : function() {
									bootbox.alert("网络不稳定,保存失败");
								}
							});
						});

	});
</script>